import Vue from "vue";
import Vuex from "vuex";
import createPersistedState from "vuex-persistedstate";


import basket from "../views/basket/store";
import order from "../views/order/store";
import list from "../views/list/store";
import register from "../views/register/store";
import login from "../views/login/store";


//引入vuex
Vue.use(Vuex)


//创建store实例

const store = new Vuex.Store({
    modules:{
        basket,
        order,
        list,
        register,
        login
    },
    plugins:[
        createPersistedState(
            {
                key:"token",
                storage: window.sessionStorage,
                reducer(val) {
                    return {"login":{token:val.login.token}}
                }

            })
    ]
})






export default store


